package com.meeting.controller.employee;

import com.meeting.dto.RoomStatusQueryDTO;
import com.meeting.dto.RoomStatusUpdateDTO;
import com.meeting.service.RoomsService;
import com.meeting.vo.Result;
import com.meeting.vo.RoomGridStatusVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDate;
import java.util.List;

@Slf4j
@RestController
@RequestMapping("/emp/rooms")
@Tag(name = "员工管理会议室接口")
public class EmpRoomController {
    @Autowired
    private RoomsService roomsService;

    @GetMapping("/list")
    @Operation(summary = "员工查看会议室状态")
    public Result getRoomStatusGrid(RoomStatusQueryDTO roomStatusQueryDTO){
        log.info("查询的具体时间{}",roomStatusQueryDTO);
        RoomGridStatusVO roomStatusGrid = roomsService.getRoomStatusGrid(roomStatusQueryDTO);
        return Result.success(roomStatusGrid);
    }

    @PutMapping("/{roomId}/{status}")
    @Operation(summary = "员工更改会议室状态")
    public Result setStatus(@PathVariable Integer roomId,@PathVariable Integer status){
        log.info("员工更改会议室状态{},{}",roomId,status);
        roomsService.setRoomsStatus(roomId,status);
        return Result.success();
    }

    @PostMapping("/use")
    @Operation(summary = "员工将会议室状态更改为使用中")
    public Result setToUsing(@RequestBody RoomStatusUpdateDTO dto){
        roomsService.setToUsing(dto);
        return Result.success();
    }

    @PostMapping("/repair")
    @Operation(summary = "员工将会议室状态更改为维修状态")
    public Result setToRepair(@RequestBody RoomStatusUpdateDTO dto) {
        roomsService.setToRepair(dto.getRoomId());
        return Result.success();
    }

    @PostMapping("/idle")
    @Operation(summary = "员工将会议室状态更改为空闲")
    public Result setToIdle(@RequestBody RoomStatusUpdateDTO dto) {
        roomsService.setToIdle(dto.getRoomId());
        return Result.success();
    }
}
